// 权限管理
import { computed } from 'vue'
import { useUserStore } from '@/store'

export default function useFeature() {
    const userStore = useUserStore()

    // 权限列表
    const feature = computed(() => userStore.feature)

    // 检测权限
    const isHasFeature = code => {
        if (process.env.NODE_ENV === 'production') {
            // 生产环境
            return feature.value.includes(code) || feature.value.includes('all')
        } else {
            // 开发环境
            return true
        }
    }

    return {
        feature,
        isHasFeature
    }
}